import Vue from 'vue';
//引入vue-router
import VueRouter from 'vue-router';
//引用页面
import signUp from "@/components/SignUp.vue";
import login from "@/components/LoginComponent.vue";
import indexComponent from "@/components/IndexComponent.vue";
import welcomeComponent from "@/components/index/WelcomeComponent.vue";
import dateComponent from "@/components/index/DateComponent.vue";
import projectsComponent from "@/components/index/ProjectsComponent.vue";
//第三方库需要use一下才能用
Vue.use(VueRouter)
//定义routes路由的集合，数组类型
const routes = [
    //单个路由均为对象类型，path代表的是路径，component代表组件
    //配置重定向
    {
        path: "/login",
        component: login
    },
    {
        path: '/sign-up',
        component: signUp
    },
    {
        path: '/',
        component: indexComponent
    }, {
        path: '/index',
        component: indexComponent,
        children: [{
            path: '/welcome',
            component: welcomeComponent
        }, {
            path: '/date',
            component: dateComponent
        }, {
            path: "/projects",
            name: "projects",
            component: projectsComponent
        }
        ]
    }
]

//实例化VueRouter并将routes添加进去
const router = new VueRouter({
    //ES6简写，等于routes：routes
    routes
});

//抛出这个这个实例对象方便外部读取以及访问
export default router
